<!DOCTYPE html>
<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">

<head>
    <title>添加景点</title>
    <meta http-equiv="Content-Type" content="multipart/form-data;charset=utf-8"/>
    <link type="text/css" rel="stylesheet" th:href="@{/asserts/css/style_admin.css}" />
    <!-- BootStrapCss -->
    <link rel="stylesheet" th:href="@{/asserts/css/bootstrap.min.css}">
    <script type="text/javascript" th:src="@{/asserts/js/jquery-3.5.1.js}"></script>
    <script type="text/javascript" th:src="@{/asserts/js/menu.js}"></script>
</head>


<body>
<!--通用顶栏-->
<div th:insert="~{admin/commons_admin::top_menu}"></div>

<!--主体-->
<div id="content">
    <!--侧边栏-->
    <div class="left_menu" th:replace="~{admin/commons_admin::left_menu}"></div>

    <div class="m-right">

        <div class="right-nav">
            <ul>
                <li style="margin-left:25px;">您当前的位置：</li>
                <li><a href="#">景点管理</a></li>
                <li>></li>
                <li><a href="#">添加景点</a></li>
            </ul>
        </div>

        <!--主体内容-->
        <div class="main">
            <form th:action="@{/admin/attraction/update}" method="post" enctype="multipart/form-data">

                <h2 class="col-sm-6 offset-3 text-primary" style="text-align: center;margin-bottom: 2rem" th:text="${msg}"></h2>

                <div class="input-group input-group-lg mb-3 col-sm-6 offset-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="">景区名称</span>
                    </div>
                    <input required name="attractionName" type="text" class="form-control" th:value="${attraction.getAttractionName()}">
                    <input required name="attractionCity" type="text" class="form-control" th:value="${attraction.getAttractionCity()}">
                    <input required name="attractionId" th:value="${attraction.getAttractionId()}" hidden="hidden">
                </div>

                <div class="input-group input-group-lg mb-3 col-sm-6 offset-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text">景区地址</span>
                    </div>
                    <input required name="attractionAddress" type="text" class="form-control" th:value="${attraction.getAttractionAddress()}">
                </div>

                <div class="input-group mb-3 col-sm-6 offset-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text">上传图片</span>
                    </div>

                    <div class="custom-file">
                        <input name="file" type="file" class="custom-file-input" id="select_file" onchange="onChange()">
                        <input required type="text" th:value="${attraction.getAttractionPic()}" hidden="hidden" name="attractionPic">
                        <label class="custom-file-label" id="select_file_tip" th:text="${attraction.getAttractionPic()}">选择文件..</label>
                    </div>
                </div>


                <div class="input-group input-group-lg mb-3 col-sm-6 offset-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text">景区负责人</span>
                    </div>
                    <input required name="attractionContacter" type="text" class="form-control" th:value="${attraction.getAttractionContacter()}">

                    <div class="input-group-prepend">
                        <span class="input-group-text">人均消费</span>
                    </div>
                    <input required name="attractionCost" type="text" class="form-control" th:value="${attraction.getAttractionCost()}">

                </div>

                <div class="input-group input-group-lg mb-3 col-sm-6 offset-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text">联系电话</span>
                    </div>
                    <input required name="attractionPhone" type="text" class="form-control" th:value="${attraction.getAttractionPhone()}">
                </div>


                <div class="input-group input-group-lg mb-3 col-sm-6 offset-3">
                    <div class="input-group">
                        <textarea style="height: 15rem;font-size: 14px" name="attractionText" class="form-control-lg col-sm-12" placeholder="景区描述..." th:text="${attraction.getAttractionText()}"></textarea>
                    </div>
                </div>


                <button type="submit" class="btn-warning btn btn-lg col-sm-2 offset-4">修改</button>
                <a class="btn-primary btn btn-lg col-sm-2 text-white" th:href="@{/toSceneryInfo/}+${attraction.getAttractionId()}">查看</a>



            </form>

        </div>
    </div>
</div>


<!--通用footer-->
<div th:insert="~{admin/commons_admin::footer}"> </div>

<script>
    /**
     * 选择图片时,input框显示文件名。
     */
    function onChange(){
        var filename = document.getElementById("select_file").value;
        filename = filename.split("\\");//将 \ 转义一下
        document.getElementById("select_file_tip").innerText=filename[filename.length-1];
        // if(truefilename)
    }

</script>
</body>
</html>
